
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp_int(const void* p1, const void* p2)
{
	return *(int*)p1 - *(int*)p2;
}
void Print_arr(int* p1, int sz)
{
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%d ", *(p1 + i));
	}
}
void test1()
{
	int arr[10] = { 9,6,45,3,2,1,10,11,23,56 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	qsort(arr, sz, sizeof(arr[0]), cmp_int);
	Print_arr(arr, sz);
}
struct st
{
	char name[20];
	int age;
};
int by_name(const void* p1, const void* p2)
{
	return strcmp((struct st*)p1, (struct st*)p2);
}
void test2()
{
	struct st arr[3] = { { "zhangsan",54 }, { "lisi",45 }, { "wangwu",34 } };
	int sz = sizeof(arr) / sizeof(arr[0]);
	qsort(arr, sz, sizeof(arr[0]), by_name);
}
int main()
{
//	test1();
	test2();
	return 0;
}